﻿Imports BUS, DTO
Public Class frmcapnhatloaisach
    Private Sub LoadLoaiSach()
        dgvDanhSachLoaiSach.Rows.Clear()
        Dim bus As New LoaiSachBUS()
        Dim dsLS As New List(Of LoaiSachDTO)
        dsLS = bus.LayDSLoaiSach()

        For i As Integer = 0 To dsLS.Count - 1
            dgvDanhSachLoaiSach.Rows.Add(dsLS(i).MaTheLoai, dsLS(i).TenTheLoai)
        Next
    End Sub

    Private Sub frmcapnhatloaisach_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadLoaiSach()
    End Sub

    Private Sub SimpleButton_CapNhat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton_CapNhat.Click
        If dgvDanhSachLoaiSach.CurrentRow.Index >= 0 Then
            Dim frm As New frmxlcapnhatloaisach()
            frm.MaloaiSach = dgvDanhSachLoaiSach.Item(0, dgvDanhSachLoaiSach.CurrentRow.Index).Value
            If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then
                LoadLoaiSach()
            End If
        Else
            MessageBox.Show("Chưa chọn loại sách !")
        End If
    End Sub
End Class